﻿using System;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Red.Controls.Shell;
using Red.Core.Extensions;

namespace Red.Toolkit.Config
{
    [Export( typeof( IEditorInfo ) )]
    public class EditorInfo : IEditorInfo
    {
        public string Name
        {
            get { return "Config Editor"; }
        }

        public Type WindowClass
        {
            get { return typeof( ConfigWindow ); }
        }

        public Type SettingsClass
        {
            get { return typeof( UserSettings ); }
        }
    }

    /// <summary>
    /// Interaction logic for ConfigWindow.xaml
    /// </summary>
    public partial class ConfigWindow : RedEditorWindow
    {
        public ConfigWindow( IEditorHost host, EditorInstanceData instanceData, EditorSharedData sharedData )
            : base( host, instanceData, sharedData )
        {
            SetDataContext().DoNotAwait();
            InitializeComponent();
        }

        private async Task SetDataContext()
        {
            DataContext = await SharedData.EngineObjectRoot;
        }
    }
}
